using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{
	private float myMovementSpeedXAxis;
	private float myMovementSpeedZAxis;
	public float myMovementFriction;
	public float movementSpeed;
	private bool movementAWSwitch;
	private bool movementASSwitch;
	private bool movementSDSwitch;
	private bool movementDWSwitch;
	
	private float countSec;
	private int countMin;
	
	private int myPoints;
	
	// Use this for initialization
	void Start ()
	{
		//transform.position.x = myValueX;
	}
	
	// Update is called once per frame
	void Update ()
	{
		countSec += Time.deltaTime;
		if(countSec >= 59)
		{
			countMin++;
			countSec = 0;
		}
		
		//the strafe right key
		float localMovementSpeed = movementSpeed*Time.deltaTime;

		if(Input.GetKey(KeyCode.D))
		{
				//Debug.Log("Pressed the D key");
				myMovementSpeedXAxis += localMovementSpeed;
				
				transform.Translate(myMovementSpeedXAxis, 0, 0, Space.Self);
		}	
		
		//the backward key
		if(Input.GetKey(KeyCode.S))
		{
				//Debug.Log("Pressed the S key");
				myMovementSpeedZAxis -= localMovementSpeed;
				
				transform.Translate(0, 0, myMovementSpeedZAxis, Space.Self);
		}
		
		//the strafe left key
		if(Input.GetKey(KeyCode.A))
		{
				//Debug.Log("Pressed the A key");
				myMovementSpeedXAxis -= localMovementSpeed;
				
				
				transform.Translate(myMovementSpeedXAxis, 0, 0, Space.Self);
		}
		
		//the forward key
		if(Input.GetKey(KeyCode.W))
		{
				//Debug.Log("Pressed the W key");
				myMovementSpeedZAxis += localMovementSpeed;
			
				transform.Translate(0, 0, myMovementSpeedZAxis, Space.Self);
		}
		
		myMovementSpeedXAxis *= myMovementFriction;
		myMovementSpeedZAxis *= myMovementFriction;
		
		Vector3 pos = transform.position;
		pos.y = 0;
		transform.position = pos;
	}

	void OnGUI()
	{	
		//the clock located in the upperleft corner
		GUI.Box(new Rect(0, 0, Screen.width * 0.15f, Screen.height * 0.06f), "Time: " + countMin + " : " + (int)countSec);
		//the powerup textbox located below the clock
		GUI.Box(new Rect(0, Screen.height * 0.06f, Screen.width * 0.15f, Screen.height * 0.06f), "PowerUp Text");
		//the points box located at the rightside of the minimap
		GUI.Box(new Rect(Screen.width * 0.70f, 0, Screen.width * 0.15f, Screen.height * 0.06f), "Points: " + myPoints);
	}
}
